import 'dart:math';

import 'package:flutter_ahj_app/app/HttpRequest.dart';
import 'package:flutter_ahj_app/base/basewidget/model/BaseModel.dart';
import 'package:rxdart/rxdart.dart';

class FeedbackModel extends BaseModel{

  BehaviorSubject _behaviorSubject = BehaviorSubject();
  BehaviorSubject _errbehaviorSubject = BehaviorSubject();

  Stream get dataSteam => _behaviorSubject.stream;
  Stream get errorSteam => _errbehaviorSubject.stream;


  getData(String content, String username){

    HttpRequest.systemFeedback(content, username).listen((request){

      String msg = request["msg"];
      _behaviorSubject.add(msg);
    },onError: (e){

      _behaviorSubject.add(null);
      _errbehaviorSubject.add(e.toString());
      errorData.add(e);
    });
  }

      @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();

    if(_behaviorSubject != null){
      _behaviorSubject.close();
    }
    
    if (_errbehaviorSubject != null) {
      _errbehaviorSubject.close();
    }
    
  }

}